package com.example.springbootvue.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.example.springbootvue.entity.Emp;
import com.example.springbootvue.service.IEmpService;
import com.example.springbootvue.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yz
 * @since 2023-03-07
 */
@RestController
@RequestMapping("/emp")
@CrossOrigin
@Api(tags = "员工操作接口")
public class EmpController {
    @Autowired
    private IEmpService iEmpService;
    @GetMapping("getAll/{currentPage}/{pageSize}")
    @ApiOperation(value = "获取员工表和部门表的数据")
    public Result<IPage<Emp>> getAll(@ApiParam(value = "当前页") @PathVariable Integer currentPage,@ApiParam(value = "当前显示几条数据") @PathVariable Integer pageSize){

        return iEmpService.getAll(currentPage,pageSize);
    }
    @DeleteMapping("delId/{id}")
    @ApiOperation(value = "根据id删除员工表的数据")
    public boolean getdelId(@ApiParam(value = "删除的id") @PathVariable Integer id){
        System.out.println("----------"+id);
        return iEmpService.removeById(id);

    }
}

